import request from '@/utils/request'
import { transformQueryCondition } from '@/utils'
import qs from 'qs'
// import qs from 'qs'
// 复合检索
export function compositeSelect(query) {
  const searchCon = transformQueryCondition(query)
  return request({
    url: `/uums/SysUserCompound/selectUsercompound?orgId=${query.orgId}`, // url: '/uums/SysUserPtOrg/selectExistUser?orgId=' + query.orgId,
    method: 'POST',
    data: searchCon
  })
}

// 复合检索
export function selectNoExistUser(query) {
  const searchCon = transformQueryCondition(query)

  return request({
    url: '/uums/SysUserPtOrg/selectNoExistUser?orgId=' + query.id,
    method: 'POST',
    data: searchCon
  })
}

// 组织机构Tree
export function getOrgTree(searchCon) {
  searchCon.status = '0,1'
  const search = qs.stringify(searchCon)
  return request({
    url: '/uums/SysOrgInfo/treeById',
    method: 'POST',
    data: search
  })
}
// 栏目保存
export function saveColumnTree(searchCon) {
  searchCon.status = '0'
  const search = qs.stringify(searchCon)
  return request({
    url: '/uums/SysOrgInfo/treeById',
    method: 'POST',
    data: search
  })
}
// 栏目查询
export function searchColumnTree(searchCon) {
  if (searchCon.type) {
    return request({
      url: 'zcmtask' + '/zcm/appNavigationCategory/findModelCategoryTreeByType?userId=' + searchCon.userId + '&type=' + searchCon.type,
      method: 'POST',
      data: searchCon
    })
  } else {
    return request({
      url: 'zcmtask' + '/zcm/appNavigationCategory/findModelCategoryTree?userId=' + searchCon.userId,
      method: 'POST',
      data: searchCon
    })
  }
}
// 强制删除
export function forceDeleteItem(data) {
  return request({
    url: '/uums/SysUserPtOrg/force',
    method: 'DELETE',
    data: data
  })
}
// 插入
export function insertItem(data) {
  return request({
    url: '/uums/SysUserPtOrg',
    method: 'POST',
    data: data
  })
}

// 更新
export function updateItem(data) {
  return request({
    url: '/uums/SysUserPtOrg/' + data.orgId + '/' + data.userId,
    method: 'PUT',
    data: data
  })
}
